package com.atxyj.prototype.mode;

/**
 * 原型模式应用实例：【例2】用原型模式生成“三好学生”奖状。
 */
public class ProtoTypeCitationDemo {

    public static void main(String[] args) throws CloneNotSupportedException {
        Citation citation1 = new Citation("lisa", "同学：在2016学年第一学期中表现优秀，被评为三好学生。","北京大学");
        citation1.display();
        Citation citation2 = (Citation)citation1.clone();
        citation2.setName("jennie");
        citation2.display();
    }
}
class Citation implements Cloneable{

    String name;
    String info;
    String college;

    public Citation(String name, String info, String college) {
        this.name = name;
        this.info = info;
        this.college = college;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return (this.name);
    }

    void display() {
        System.out.println(name+info+college);
    }

    public Object clone() throws CloneNotSupportedException{
        System.out.println("奖状拷贝成功!");
        return (Citation) super.clone();
    }


}